<script>
import { getShowNginxPicUrl } from "@/utils/settings"

export default {
  name: "tipPopups",
  data() {
    return {
      promise: {
        resolve: null,
        reject: null,
      },
      currentDay: 0,
      targetDay: 0,
    }
  },
  methods: {
    getShowNginxPicUrl,
    open(currentDay, targetDay) {
      return new Promise((resolve, reject) => {
				this.currentDay = currentDay
				this.targetDay = targetDay
        this.promise.resolve = resolve
        this.promise.reject = reject
        this.$refs.popup.open()
      })
    },
  },
}
</script>

<template>
  <uni-popup ref="popup" type="center" :is-mask-click="false">
    <view class="popup-content">
      <image class="icon" :src="getShowNginxPicUrl('NQ5egh4qpA1YJwYcw1tr.png')"></image>

      <view class="message">
        <text>当前正进行</text>
        <text class="number" style="color: #f3991f">Day{{ currentDay }}</text>
        <text>学习任务，是否切换成</text>
        <text class="number" style="color: #2cb980">Day{{ targetDay }}</text>
        <text>学习任务?</text>
      </view>

      <view class="footer-btn">
        <view
          class="cancel-btn btn"
          @click="
            () => {
              promise.reject()
              $refs.popup.close()
            }
          "
          >取消</view
        >
        <view
          class="confirm-btn btn"
          @click="
            () => {
              promise.resolve()
              $refs.popup.close()
            }
          "
          >确定</view
        >
      </view>
    </view>
  </uni-popup>
</template>

<style scoped lang="scss">
.popup-content {
  padding: {
    top: 132rpx;
    left: 40rpx;
    right: 40rpx;
    bottom: 50rpx;
  }
  width: 600rpx;
  background: white;
  border-radius: 30rpx;
  position: relative;
  > .icon {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -108rpx;
    width: 310rpx;
    height: 216rpx;
  }
  > .message {
    font-size: 30rpx;
    > .number {
      margin: 0 10rpx;
    }
  }
  > .footer-btn {
    margin-top: 40rpx;
    display: flex;
    justify-content: space-between;
    > .btn {
      padding: 20rpx 80rpx;
      font-size: 30rpx;
      border-radius: 10rpx;
      &.cancel-btn {
        background: #f0f0f0;
      }
      &.confirm-btn {
        background: #2cb980;
        color: #fff;
      }
    }
  }
}
</style>
